<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
<script type="text/javascript">
function  onLoad(){
	if(parseInt("${result}")>0){
		alert("保存成功");
	}else if(parseInt("${result}")<0){
		alert("保存失败");
	}
}

function  goBack(){
	window.history.back(-1);
}

function  checkpic(){
	if($("#pic1").val()!=""&&$("#pic2").val()!=""){
		document.forms[1].submit();		
	}else{
	    alert("请上传所有图片！");
	}

}


function save(){
	var str_data=$("#startform input").map(function(){
		   return ($(this).attr("name")+'='+$(this).val());
		 }).get().join("&") ;
    $.ajax({
        url:"${ctx}/appFrameStart/updateAppFrameStart",
        type: "POST",      
        dataType:"json",
        data: str_data,
        async: false,
        success: function(data) {
        	if(data.flag>0){
	            alert("保存成功！");	
	            window.location.reload();
        	}
/* 	          $.each(data, function(index, element) {
             window.location.reload();
          }); */
        },
        error: function() {
          alert("error");
        }
      });
	
}

function  changeValue(moduleValue){
	   document.getElementById("start_module_id").value=moduleValue;	
}
/*  function ajaxRequest() {
    $.ajax({
      url: "${ctx}/uploadpic/one?appid=${appFrameStart.appId}",
      type: "POST",
      dataType: "json",
      data:$("#picinfo").serialize(),
      async: false,
      success: function(data) {
        alert("添加成功！");
        $.each(data, function(index, element) {
           window.location.reload();
        });
      },
      error: function() {
        alert("error");
      }
    });
  }  */
</script>
</head>
<body  onload="onLoad()">
<div class="panel panel-default">
   <div class="panel-heading">
      <h3 class="panel-title">
          App基本设置信息
      </h3>
   </div>
   <div class="panel-body">
<form class="form-horizontal" role="form" id="startform"  action="${ctx}/appFrameStart/updateAppFrameStart" method="post">
      <div class="form-group">
		<label for="APP_ID" class="col-xs-2 control-label">应用标识start</label>
		<div class="col-xs-4">
		<input type="text" class="form-control" id="APP_ID"  name="appId" readonly="readonly"   value="${appFrameStart.appId}"   placeholder="APP_ID">
	    </div>
	    <label for="app_icon" class="col-xs-2 control-label">应用图标名称</label>
		<div class="col-xs-4">
		<input type="text" class="form-control" id="app_icon"  name="appIcon"  readonly="readonly" value="${appFrameStart.appIcon}"  placeholder="app_icon">
	    </div>
	  </div>   
	  <div class="form-group">
		<label for="app_icon_size" class="col-xs-2 control-label">图标尺寸</label>
		<div class="col-xs-4">
		<input type="text" class="form-control" id="app_icon_size"   name="appIconSize"   readonly="readonly"  value="${appFrameStart.appIconSize}"   placeholder="app_icon_size">
	    </div>
	    <label for="app_starting_icon" class="col-xs-2 control-label">启动画面</label>
		<div class="col-xs-4">
		<input type="text" class="form-control" id="app_starting_icon"  name="appStartingIcon"   readonly="readonly"  value="${appFrameStart.appStartingIcon}"   placeholder="app_starting_icon">
	    </div>
	  </div>
	  <div class="form-group">
		<label for="app_starting_icon_size" class="col-xs-2 control-label">启动图片尺寸</label>
		<div class="col-xs-4">
		<input type="text" class="form-control" id="app_starting_icon_size"  name="appStartingIconSize"  readonly="readonly"  value="${appFrameStart.appStartingIconSize}"  placeholder="app_starting_icon_size">
	    </div>
	    <label for="start_module_id" class="col-xs-2 control-label">启动模块</label>
		<div class="col-xs-4">
 		<input type="hidden" class="form-control" id="start_module_id"  name="startModuleId"  value="${appFrameStart.startModuleId}"   placeholder="start_module_id">
	   
	   	      <select class="form-control" id="" name="startModuleId" value="${appFrameStart.startModuleId}" onclick="changeValue(this.value)">
<%--              <c:if test="${appModuleParam.isMustNeed==1}">
                <option value="1">是</option>        
            </c:if>
            <c:if test="${appModuleParam.isMustNeed==2}">
                <option value="2">否</option>        
            </c:if> --%>
            
            <c:forEach items="${ModuleList}" var="module"  varStatus="s" >
            <c:choose>
			             <c:when  test="${module['module_id']==appFrameStart.startModuleId}">
			                <option value="${module['module_id']}" name="startModuleId"  selected="selected">${module['module_name']}</option>      
			             </c:when >
			             <c:otherwise> 
			                 <option value="${module['module_id']}"  name="startModuleId">${module['module_name']}</option>
                         </c:otherwise>
<%--             	          <option value="${module['module_id']}">${module['module_name']}</option> --%>
            </c:choose>
            </c:forEach>
	      </select>
	   
	    </div>
	 </div>   
	  <div class="form-group">
		<label for="app_copyright" class="col-xs-2 control-label">版权信息</label>
		<div class="col-xs-4">
		<input type="text" class="form-control" id="app_copyright"  name="appCopyright"  value="${appFrameStart.appCopyright}"   placeholder="app_copyright">
	    </div>	
	  </div>
<!-- 	  </form>	  --> 

	  <div class="form-group  text-center">
<!-- 	  <div class="row  vertical-middle-sm"> 
         <div class="col-xs-offset-2 col-xs-10">-->
         <button type="button" class="btn btn-default"  onclick="save();">保存</button>
         <button type="button" class="btn btn-default"   onclick="goBack();">返回</button>
<!--          </div>
      </div> -->
      </div>
 </form> 
   </div>
</div>

<div class="panel panel-default">
   <div class="panel-heading">
      <h3 class="panel-title">
                   上传图片
      </h3>
   </div>
   <div class="panel-body">
   	   <form  id="picinfo" action="${ctx}/uploadpic/one?appid=${appFrameStart.appId}" method="post"  enctype="multipart/form-data">
   	   <div class="form-group">
	    <label for="pic1" class="col-xs-2 control-label">应用图标</label>
		<div class="col-xs-10">
		<input type="file" class="form-control" name="pic1" id="pic1"   accept=".bmp,.jpg,.jpeg,.png,.gif"  placeholder="app_icon">
	    </div>
	  </div> 
	  <br><br>
	  <div class="form-group">
	    <label for="pic2" class="col-xs-2 control-label">启动画面</label>
		<div class="col-xs-10">
		<input type="file" class="form-control" name="pic2" id="pic2" accept=".bmp,.jpg,.jpeg,.png,.gif"  placeholder="app_icon">
	    </div>
	  </div>  
	  	  <br><br>
	   <div class="form-group  text-center">   
  	           <button type="button" class="btn btn-default"  onclick="checkpic();">上传</button>    
<!--	         <button type="button" class="btn btn-default"  onclick="ajaxRequest();">上传</button> -->
	   </div>
<!--          ：       <input type="file" name="uploadfile1" id>
                  上传文件：       <input type="file" name="uploadfile2"  id="icon">
           <input type="submit" value="上传"  > -->
      </form>   
   </div>
</div>
   

<%@ include file="/page/foot.html" %>
